﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 斐波那契数列
{
	class Program
	{
		/// <summary>
		/// 第i项的值
		/// </summary>
		/// <param name="i"></param>
		/// <returns></returns>
		public static int GetNums(int i)
		{
			if (i == 1 || i == 2)
				return 1;
			return GetNums(i - 1) + GetNums(i - 2);

		}
		/// <summary>
		/// 求和
		/// </summary>
		/// <param name="i"></param>
		/// <returns></returns>
		public int sum(int i)   //所有数的和
		{
			if (i == 1)
				return 1;
			else if (i == 2)
				return 2;
			else
				return sum(i - 1) + sum(i);

		}
		static void Main(string[] args)
		{
			int num = GetNums(4);
			Console.WriteLine(num);
			Console.ReadLine();
		}
	}
}
